package com.gopay.scheduler.job;

/*
 * Copyright (c) 2016. www.gopay.com.cn Inc.All rights reserved.
 * 项目名称 : 国付宝内部对账(2016/11/29)
 * 文件名称 : IcTradeBalanceJob
 * 创建日期 : 16-12-22 下午4:52
 * Author   : baiyunpeng
 *
 */

import com.gopay.common.domain.ic.IcTradeBalance;
import com.gopay.remote.cps.ic.InnerCheckRemoteService;
import com.gopay.scheduler.GopayBaseJob;
import com.gopay.scheduler.util.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class IcTradeBalanceJob extends GopayBaseJob {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

   @Resource(name = "InnerCheckRemoteService")
    private InnerCheckRemoteService innerCheckRemoteService;


    @Override
    protected void doJobInternal() {
        Map<String,Object> dataMap = new HashMap();
        Date beginDate = new Date();
        Calendar insertDate = Calendar.getInstance();
        insertDate.setTime(beginDate);
        insertDate.set(Calendar.DATE, insertDate.get(Calendar.DATE) - 1);
        dataMap.put("insertDate",DateUtils.format(insertDate.getTime(),"yyyyMMdd"));
        try {
            logger.info("国付宝内部对账 : 交易借贷平衡  program is start running");
            innerCheckRemoteService.coverAcpsToIcTradeBalance(new IcTradeBalance(),dataMap);
            logger.info("国付宝内部对账 : 交易借贷平衡  program is executed successfully");
        } catch (Exception e) {
            logger.error("国付宝内部对账 : 交易借贷平衡异常",e.getMessage());
        }
    }
}
